package com.kokoiko.customview;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class GridAdapter extends BaseAdapter{

	Context context;
	ArrayList<Bitmap> icons;
	public GridAdapter(Context context, ArrayList<Bitmap> icons) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.icons = icons;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		Log.i("size", String.valueOf(icons.size()));
		return icons.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImageView imgv;
		if(convertView == null){
			imgv = new ImageView(context);
			imgv.setLayoutParams(new GridView.LayoutParams(50, 50));
			imgv.setScaleType(ImageView.ScaleType.CENTER);
		}else{
			imgv = (ImageView) convertView;
		}
		imgv.setImageBitmap(icons.get(position));	
		return imgv;
	}

}
